package com.car.web.Car;

import com.car.domain.Car;
import com.car.domain.Page;
import com.car.server.impl.AdminPageCarServerImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/car/InquireAllCarByPage")
public class InquireAllCarByPage extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //1.获取页面提交的页码数
        String strPage = req.getParameter("currentPage");
        //2.创建业务层对象,调用分页查询方法

        Page<Car> pageBean = new AdminPageCarServerImpl().findPageByCurrentPage(
                Integer.parseInt(strPage),10);
        //3.保存到域对象,转发到分页页面显示
        req.setAttribute("pageBean",pageBean);
        req.getRequestDispatcher("ShowAllCarPage.jsp").forward(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }

}
